<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%
	String filePath = request.getParameter("filePath");
	if(filePath==null){
		filePath="";
	}
 %> 
<script type="text/javascript" src="<%=path %>/resource/lib/plugins/ajaxfileupload.js"></script>
<input type="hidden" id="filePath" value="<%=filePath %>"/>
<script type="text/javascript">
	var serverPrefixPath = "";
	//页面加载
	$(function(){
		//添加上传组件
		$(".upfileBoxs").each(function(index, el){
		    var num = el.id.split("fileUpload")[1];
    		$(this).append(addUpfileBox(num));
    	});
		//获取服务器路径前缀
		$.ajax({
			type: 'get',
			url: '<%=path%>/system/sysulfilesrec/getServerPath.do',
			success:function(msg){
				serverPrefixPath = msg;
				console.log(serverPrefixPath);
			}
		});
	});
	
	//添加上传组件方法
	function addUpfileBox(num) {
		$Html=CreatUploadInputBox({
			id:"uploads" + num,  //id跟着序号走
			clearLine: true,
			deletable: false,
			finishClear: true //上传成功后清空文本框
		});
		return $Html;
	}

    //上传方法
    function ajaxFileUploadImg(fileId, callback) {
        if ($("#" + fileId).val() == "") {
            $.ligerDialog.SQalert({content: "请选择要上传的附件！", SQ_type: "warning"});
            return false;
        }
        var _filePath = $("#filePath").val();
        var wait_dialog = $.ligerDialog.SQalert({content: '上传中,请稍后...', SQ_type: "waitting"});
        //文件上传
        $.ajaxFileUpload({
            url: '<%=path%>/system/sysulfilesrec/upload.do',
            secureuri: false,
            fileElementId: fileId,  //上传框的id
            dataType: 'json',
            data: {filePath: _filePath},
            success: function (msg) {
                if (msg.success == 1) {
                    callback(msg.data);
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            },
            complete: function () {
                wait_dialog.close();
            }
        });
    }

</script>
